<%--
  Created by IntelliJ IDEA.
  User: zheng
  Date: 2021/6/27
  Time: 22:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>芜湖起飞 - 经济餐</title>
    <link rel="icon" type="image/png" sizes="16px" href="${pageContext.request.contextPath}/statics/images/icon.png"/>
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/meals-main.css"/>
</head>
<body>
<div class="container-fluid">
    <div class="row bg">
        <div class="sidebar col-lg-2">
            <img src="${pageContext.request.contextPath}/image/icon-big.png" width="200px" class="img-responsive center-block" />
            <ul id="main-nav" class="nav nav-tabs nav-stacked">
                <li><a href="${pageContext.request.contextPath}/features/doing/meals">自主选餐</a></li>
                <li><a href="${pageContext.request.contextPath}/features/doing/seat">随心选座</a></li>
                <li><a href="${pageContext.request.contextPath}/features/center">个人信息</a></li>
                <li><a href="${pageContext.request.contextPath}">返回首页</a></li>
            </ul>
            <p class="welcome text-center">欢迎您，${sessionScope.user.user_phone}<br />
                您的机票单号为：${ticket.fo_no}</p>
        </div>
        <div class="meallect col-lg-9">
            <div class="type">
                <p class="lect">餐品类型：
                    <select class="foodstyle" onchange="window.location.href = '${pageContext.request.contextPath}/features/meals/pro'">
                        <option >特惠餐</option>
                        <option>定制餐饮</option>
                    </select>
                </p>
            </div>

            <div class="ifm col-lg-offset-3">
                <h5 class="information1">航班信息：</h5>
                <h6 class="information2">
                    机票单号：${ticket.fo_no}
                    航空班次：${ticket.fo_flight.flight_no} &nbsp;&nbsp;&nbsp;
                    飞机型号：${ticket.fo_flight.flight_type.type_model}&nbsp;&nbsp;&nbsp;

                </h6>
                <h5 class="information3">个人信息：</h5>
                <h6 class="information4">
                    手机号码：${sessionScope.user.user_phone}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    性别：${user_sex}&nbsp;&nbsp;&nbsp;&nbsp;
                    所选餐类：经济餐&nbsp;&nbsp;&nbsp;
                    起飞时间:${ticket.fo_flight.flight_time}
                </h6>
            </div>
            <div class="menu">
                <div class="dish">
                    <c:forEach var="meal" items="${meals}">
                        <div class="photo">
                            <img src="${pageContext.request.contextPath}${meal.meal_image}" title="${meal.meal_intro}" width="100%" height="125px"/><br />

                            <label class="dishname"><input type="radio" value="${meal.meal_id}" name="dname"/>&nbsp;&nbsp;${meal.meal_name}</label>
                        </div>
                    </c:forEach>
                </div>
                <div class="footer">
                    <button type="button" id="select" class="btn2" id="sub" onclick="submitted()">确定选择</button>
                </div>
            </div>
        </div>
    </div>
</div>


<script src="https://cdn.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"></script>


</body>
<script type="text/javascript">

    function submitted(){
        $.ajax({
            url:"${pageContext.request.contextPath}/meals/free.do",
            type:"POST",
            contentType: "application/json;charset=UTF-8",
            data:JSON.stringify({
                ticketID:${sessionScope.Ticket},
                userID:${sessionScope.user.user_id},
                freeID:parseInt($("input[name='dname']:checked").val())
            }),
            dataType:"json",
            success:function (data){
                console.log(data);
                if(data.code == 0){//成功 进入选座或者首页
                    alert(data.message);
                    window.location.href='${pageContext.request.contextPath}/features/doing/center';
                }else {
                    alert(data.message);
                }
            }
        });
    }
</script>
</html>
